[PATCH] freetype: Handle failing glyph rendering
authorDavid Edmundson <davidedmundson@kde.org>
Wed, 25 Mar 2026 15:32:10 +0000 (15:32 +0000)
committerPatrick Franz <deltaone@debian.org>
Sun, 9 Aug 2026 10:38:49 +0000 (12:38 +0200)
When FT_Render_Glpyh fails the slot returns a bitmap containing a valid
width and height but a null buffer.

When we eventually memcpy this buffer we will crash. Existing error
handling in this method returns null on errors.

Pick-to: 6.10 6.8
Fixes: QTBUG-145310
Change-Id: I4737ab4d769b52f42bd1ef9037c8b9fd681a4ae8
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 1b4f4b1797bc7db3eea6ef83a34df61d7bf78e17)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Gbp-Pq: Name upstream_freetype-handle-failing-glyph-rendering.patch

src/gui/text/freetype/qfontengine_ft.cpp

index e331a4cc8158ed4d0e66c2f24ab4247d9752be02..371e01db590ea159499724494f5be924966c5057 100644 (file)
@@ -1955,11 +1955,13 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
     FT_Library_SetLcdFilter(slot->library, (FT_LcdFilter)lcdFilterType);
 
     err = FT_Render_Glyph(slot, renderMode);
-    if (err != FT_Err_Ok)
-        qWarning("render glyph failed err=%x face=%p, glyph=%d", err, face, glyph);
-
     FT_Library_SetLcdFilter(slot->library, FT_LCD_FILTER_NONE);
 
+    if (err != FT_Err_Ok) {
+        qWarning("render glyph failed err=%x face=%p, glyph=%d", err, face, glyph);
+        return nullptr;
+    }
+
     info.height = slot->bitmap.rows;
     info.width = slot->bitmap.width;
     info.x = slot->bitmap_left;